package org.finalministry.gui.action;

import javax.swing.JFileChooser;

import org.finalministry.gui.GuiMain;
import org.finalministry.importexport.FinalministryDataImportExport;

public class ImportDataAction extends GuiActionBase {

	public ImportDataAction(GuiMain guiMain) {
		super(guiMain);
	}

	@Override
	public void performAction() {

		System.out.println("Import data performed");
		final JFileChooser fc = new JFileChooser();

		fc.showOpenDialog(getGuiMain());
		FinalministryDataImportExport dataImportExport = new FinalministryDataImportExport();

		try {
			dataImportExport.importCongregation(fc.getSelectedFile());

			LoadDataIntoTree loadDataIntoTree = new LoadDataIntoTree(getGuiMain());
			loadDataIntoTree.performAction();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
